package com.leonzhangxf.client;

import com.leonzhangxf.client.invoke.RPCConsumer;
import com.leonzhangxf.service.IUserService;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;

/**
 * @author leonzhangxf
 */
@SpringBootApplication
public class ClientApplication implements ApplicationRunner {

    public static void main(String[] args) {
        new SpringApplicationBuilder(ClientApplication.class)
            .run(args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        // 获取服务，并调用远程服务
        IUserService service = (IUserService) RPCConsumer.createProxy(IUserService.class);

        while (true) {
            String result = service.sayHello("hello leon");
            System.out.println(result);
            Thread.sleep(2000);
        }
    }
}
